#include "uthash.h"
#include "stdio.h"

struct HashTable {
    int key;
    UT_hash_handle hh;
};

struct HashTable *jewelsSet;

struct HashTable *find(int ikey) {
    struct HashTable *tmp = NULL;
    HASH_FIND_INT(jewelsSet, &ikey, tmp);
    return tmp;
}

void insert(int ikey) {
    struct HashTable *rec = find(ikey);
    if (rec == NULL) {
        struct HashTable *tmp = malloc(sizeof(struct HashTable));
        tmp->key = ikey;
        HASH_ADD_INT(jewelsSet, key, tmp);
    }
}

int numJewelsInStones(char *jewels, char *stones) {
    int jewelsCount = 0;
    jewelsSet = NULL;
    int jewelsLength = strlen(jewels), stoneLength = strlen(stones);
    for (int i = 0; i < jewelsLength; ++i) {
        char jewel = jewels[i];
        insert(jewel);
    }
    for (int i = 0; i < stoneLength; ++i) {
        char stone = stones[i];
        if (find(stone) != NULL) {
            jewelsCount++;
        }
    }
    return jewelsCount;
}

int main() {
    char *jewels = "aA", *stones = "aAAbbbb";
    int ret = numJewelsInStones(jewels, stones);
    printf("%d", ret);
}

